package com.qiezikaka.kaka.ui.single;

import android.app.Activity;

import com.qiezikaka.kaka.base.BasePresenter;
import com.qiezikaka.kaka.bean.AllBean;
import com.qiezikaka.kaka.bean.BannerInfo;
import com.qiezikaka.kaka.bean.FuZhuangInfo;
import com.qiezikaka.kaka.bean.HomeCateInfo;
import com.qiezikaka.kaka.bean.ShopInfo;
import com.qiezikaka.kaka.bean.UpdataVersionInfo;
import com.qiezikaka.kaka.net.DataManager;
import com.qiezikaka.kaka.ui.MainContract;

import rx.Subscription;
import rx.functions.Action1;

public class StyleSinglePresenter extends BasePresenter<StyleSingleContract.View> implements StyleSingleContract.Presenter {

    public StyleSinglePresenter(Activity activity, StyleSingleContract.View view) {
        super(activity, view);

    }

    @Override
    public void getGoodsList(String cid, String page, String limit, String hot) {
        Subscription subscribe = DataManager.getInstance().getFuZhuanList(cid,page,limit,hot)
                .subscribe(new Action1<FuZhuangInfo>() {
                    @Override
                    public void call(FuZhuangInfo InfoData) {
                        if (InfoData != null) {
                            mView.onGoodsList(InfoData);
                        }
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        handleError(throwable);
                        throwable.printStackTrace();
                        mView.onFailer(throwable);
                    }
                });
        addSubscribe(subscribe);
    }

    @Override
    public void updateVersion() {
        Subscription subscribe = DataManager.getInstance().getUpdataVersion()
                .subscribe(new Action1<UpdataVersionInfo>() {
                    @Override
                    public void call(UpdataVersionInfo InfoData) {
                        if (InfoData != null) {
                            mView.onUpdataApp(InfoData);
                        }
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwable.printStackTrace();
                        mView.onFailer(throwable);
                    }
                });
        addSubscribe(subscribe);
    }
}
